<template>
	<view class="content">
		<view class="select">
			<view class="Time">
				<view style="min-width: 45%;padding: 15rpx;">
					入场时间:
					<picker mode="date" @change="changeEntryDate">
						<text v-if="!entryDate">请选择入场日期</text>
						<text v-else>{{entryDate}}</text>
					</picker>
					<picker mode="time" @change="changeEntryTime">
						<text v-if="!entryTime">请选择入场时间</text>
						<text v-else>{{entryTime}}</text>
					</picker>
				</view>
				<view style="min-width: 45%; padding: 15rpx;">
					出场时间:
					<picker mode="date" @change="changeOutDate">
						<text v-if="!outDate">请选择出场日期</text>
						<text v-else>{{outDate}}</text>
					</picker>
					<picker mode="time" @change="changeOutTime">
						<text v-if="!outTime">请选择出场时间</text>
						<text v-else>{{outTime}}</text>
					</picker>
				</view>
				<button style="min-width: 20%;"  @click="select">查询</button>
			</view>
		</view>
		<view class="record_list">
			<view class="record_item" v-for="(item,index) in record_data" v-show="(isShow||index<6)&&(!isSelect || (new Date(item.entryTime)>=entry && new Date(item.outTime)<=out))">
				<view class="plateNumber">{{item.plateNumber}}</view>
				<view>时间段:{{item.entryTime}}--{{item.outTime}}</view>
				<view>收费金额:{{item.monetary}}元</view>
				<view>停车场名称:{{item.parkName}}</view>
				<view>地址:{{item.address}}</view>
			</view>
			<button @click="isShow=true" v-show="!isShow">查看更多</button>
		</view>
	</view>
</template>

<script>
	import {
		http
	} from "../../utils/request.js"
	export default {
		data() {
			return {
				record_data: [],
				isShow: false,
				entryDate: "",
				entryTime: "",
				outDate:"",
				outTime:"",
				entry:"",
				out:"",
				isSelect:false
			}
		},
		created() {
			const that = this
			uni.showLoading({
				title: "加载中..."
			})
			http({
				url: "/prod-api/api/park/lot/record/list"
			}).then((res) => {
				that.record_data = res.data.rows
				that.$nextTick(() => {
					uni.hideLoading()
				})
			})
		},
		methods: {
			changeEntryDate(e) {
				this.entryDate = e.target.value
			},
			changeEntryTime(e) {
				this.entryTime = e.target.value
			},
			changeOutDate(e){
				this.outDate = e.target.value
			},
			changeOutTime(e) {
				this.outTime = e.target.value
			},
			select(){
				this.isShow=true
				this.isSelect=true
				this.entry=new Date(this.entryDate+" "+this.entryTime)
				this.out=new Date(this.outDate+" "+this.outTime)
			},
		}
	}
</script>

<style>
	body,
	html {
		background-color: #ecf0f1;
	}
	picker{
		width: 80%;
		background-color: white;
		margin: 0 auto;
	}
	.Time{
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;
		text-align: center;
	}
	.content {
		width: 95%;
		margin: 20rpx;
		display: flex;
		flex-direction: column;
	}

	.record_list {
		display: flex;
		flex-direction: column;
	}

	.record_item {
		display: flex;
		flex-direction: column;
		margin: 10rpx;
		padding: 10rpx;
		box-sizing: border-box;
		background-color: #bdc3c7;
		border-radius: 5px;
	}

	.plateNumber {
		font-size: 35rpx;
		text-align: center;
		font-weight: bolder;
	}
</style>
